import React, {Component} from 'react';
import {asideNavs} from './../../navs';
import {hashHistory} from 'react-router';

export default class Black extends Component{
    componentWillMount() {
        console.log(this.props);
        //对访问的路径进行筛选，验证
        //this.verifyUrl(this.props.location.pathname);
    }

    verifyUrl = (realPath)=>{
        let url = realPath;
        if ("/" == realPath) {
            url = (asideNavs.length>0 && asideNavs[0].children != undefined
                && asideNavs[0].children.length > 0)?asideNavs[0].children[0].to:asideNavs[0].to;
        } else {
            //循环菜单
            asideNavs.forEach((item)=>{
                if (realPath == item.to){
                    url = (item.children != undefined && item.children.length > 0)?
                        item.children[0].to : item.to;
                }
            });
        }
        //重定向
        if (url != realPath){
            hashHistory.push(url);
        }else {
            //默认跳转，菜单第一列
            hashHistory.push((asideNavs.length>0 && asideNavs[0].children != undefined
                && asideNavs[0].children.length > 0)?asideNavs[0].children[0].to:asideNavs[0].to);
        }
    }


    render(){
        return (<div></div>);
    }
}